/**
 * @deprecated
 */
import React from 'react';
import { formatMessage } from 'umi';

import { commonColumn } from '@/pages/SalaryManage/utils/TableUtil';
import ExcelListBaseModel from '@/pages/SalaryManage/SalaryCalculate/ImportExcel/ExcelListBaseModel';
import { queryPayrollSocialLastImportYearMonth, queryPayrollSocial } from '@/services/salaryManage/salaryCalculate';
import { numberFormat } from '@/utils/formatterUtil';
import EmptyPlaceHolder from '@/pages/SalaryManage/components/EmptyPlaceHolder'

const numberRender = text /* , record  , index */ => text != null ? numberFormat(text, 2) : <EmptyPlaceHolder />
const numberColumn = () => ({ align: 'right', render: numberRender })

const salaryPayrollSocialModel = ExcelListBaseModel({
    namespace: 'salaryPayrollSocialModel',
    queryService: queryPayrollSocial,
    initService: queryPayrollSocialLastImportYearMonth
})

salaryPayrollSocialModel.state.columns = pagination => [
    {
        // 序号
        title: formatMessage({ id: 'salaryPayrollSocial.table.sn' }),
        dataIndex: 'sn',
        render (text, record, index) {
            return `${(pagination.current - 1) * pagination.pageSize + index + 1}`
        },
        align: 'center'
    },
    commonColumn({
        // 工号
        title: formatMessage({ id: 'salaryPayrollSocial.table.employeeCode' }),
        dataIndex: 'employeeCode'
    }),
    commonColumn({
        // 姓名
        title: formatMessage({ id: 'salaryPayrollSocial.table.name' }),
        dataIndex: 'name'
    }),
    commonColumn({
        // 个人识别号
        title: formatMessage({ id: 'salaryPayrollSocial.table.personalNo' }),
        dataIndex: 'personalNo'
    }),
    commonColumn({
        // 个人社会保险编号
        title: formatMessage({ id: 'salaryPayrollSocial.table.socialNo' }),
        dataIndex: 'socialNo'
    }),
    commonColumn({
        // 状态
        title: formatMessage({ id: 'salaryPayrollSocial.table.status' }),
        dataIndex: 'workState'
    }),
    {
        // 部门
        title: formatMessage({ id: 'salaryPayrollSocial.table.department' }),
        dataIndex: 'department',
        render: text => <div style={ { whiteSpace: 'nowrap' } }>{ text }</div>
    },
    commonColumn({
        // 社保方案
        title: formatMessage({ id: 'salaryPayrollSocial.table.socialScheme' }),
        dataIndex: 'socialInsurance'
    }),
    {
        // 总金额
        title: formatMessage({ id: 'salaryPayrollSocial.table.encryptTotalAmt' }),
        dataIndex: 'encryptTotalAmt',
        ...numberColumn()
    },
    commonColumn({
        // 入库日期
        title: formatMessage({ id: 'salaryPayrollSocial.table.warehouseDate' }),
        dataIndex: 'warehouseDate'
    }),
    {
        // 上年平均薪资
        title: formatMessage({ id: 'salaryPayrollSocial.table.encryptAverageAmt' }),
        dataIndex: 'encryptAverageAmt',
        ...numberColumn()
    },
    {
        // 建帐年月
        title: formatMessage({ id: 'salaryPayrollSocial.table.acctPeriod' }),
        dataIndex: '',
        render (text, record /* , index */) {
            const arr = []

            if (record.acctYear != null) {
                arr.push(record.acctYear)
            }

            if (record.acctMonth != null) {
                arr.push(record.acctMonth)
            }

            return arr.length === 0 ? <EmptyPlaceHolder /> : arr.join('-')
        }
    },
    commonColumn({
        // 费款所属期
        title: formatMessage({ id: 'salaryPayrollSocial.table.expensePeriod' }),
        dataIndex: 'expensePeriod'
    }),

    {
        // 养老保险费
        title: formatMessage({ id: 'salaryPayrollSocial.table.endowmentInsurance' }),
        children: [
            {
                // 养老保险费 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptOldBaseAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptOldCompanyAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 单位减免额
                // 单位减免额
                title: formatMessage({ id: 'salaryPayrollSocial.table.reduceAmt' }),
                dataIndex: 'encryptOldReduceAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 个人应缴
                // 个人应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.personAmt' }),
                dataIndex: 'encryptOldPersonAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptOldTotalAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptOldDelayAmt',
                ...numberColumn()
            },
            {
                // 养老保险费 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptOldInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 失业保险费
        title: formatMessage({ id: 'salaryPayrollSocial.table.unemploymentInsurance' }),
        children: [
            {
                // 失业保险费 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptUnemployBaseAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptUnemployCompanyAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 单位减免额
                // 单位减免额
                title: formatMessage({ id: 'salaryPayrollSocial.table.reduceAmt' }),
                dataIndex: 'encryptUnemployReduceAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 个人应缴
                // 个人应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.personAmt' }),
                dataIndex: 'encryptUnemployPersonAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptUnemployTotalAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptUnemployDelayAmt',
                ...numberColumn()
            },
            {
                // 失业保险费 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptUnemployInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 工伤保险费
        title: formatMessage({ id: 'salaryPayrollSocial.table.industrialInjury' }),
        children: [
            {
                // 工伤保险费 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptHarmBaseAmt',
                ...numberColumn()
            },
            {
                // 工伤保险费 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptHarmCompanyAmt',
                ...numberColumn()
            },
            {
                // 工伤保险费 - 单位减免额
                // 单位减免额
                title: formatMessage({ id: 'salaryPayrollSocial.table.reduceAmt' }),
                dataIndex: 'encryptHarmReduceAmt',
                ...numberColumn()
            },
            {
                // 工伤保险费 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptHarmTotalAmt',
                ...numberColumn()
            },
            {
                // 工伤保险费 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptHarmDelayAmt',
                ...numberColumn()
            },
            {
                // 工伤保险费 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptHarmInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 医疗保险费
        title: formatMessage({ id: 'salaryPayrollSocial.table.medicalInsurance' }),
        children: [
            {
                // 医疗保险费 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptHospitalBaseAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptHospitalCompanyAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 单位减免额
                // 单位减免额
                title: formatMessage({ id: 'salaryPayrollSocial.table.reduceAmt' }),
                dataIndex: 'encryptHospitalReduceAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 个人应缴
                // 个人应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.personAmt' }),
                dataIndex: 'encryptHospitalPersonAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 健康账户抵扣额
                // 健康账户抵扣额
                title: formatMessage({ id: 'salaryPayrollSocial.table.healthDeduction' }),
                dataIndex: 'encryptHospitalHealthAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptHospitalTotalAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptHospitalDelayAmt',
                ...numberColumn()
            },
            {
                // 医疗保险费 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptHospitalInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 医疗(生育)保险费
        title: formatMessage({ id: 'salaryPayrollSocial.table.maternityInsurance' }),
        children: [
            {
                // 医疗(生育)保险费 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptBirthBaseAmt',
                ...numberColumn()
            },
            {
                // 医疗(生育)保险费 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptBirthCompanyAmt',
                ...numberColumn()
            },
            {
                // 医疗(生育)保险费 - 单位减免额
                // 单位减免额
                title: formatMessage({ id: 'salaryPayrollSocial.table.reduceAmt' }),
                dataIndex: 'encryptBirthReduceAmt',
                ...numberColumn()
            },
            {
                // 医疗(生育)保险费 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptBirthTotalAmt',
                ...numberColumn()
            },
            {
                // 医疗(生育)保险费 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptBirthDelayAmt',
                ...numberColumn()
            },
            {
                // 医疗(生育)保险费 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptBirthInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 公务员医疗
        title: formatMessage({ id: 'salaryPayrollSocial.table.officialMedical' }),
        children: [
            {
                // 公务员医疗 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptPublicBaseAmt',
                ...numberColumn()
            },
            {
                // 公务员医疗 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptPublicCompanyAmt',
                ...numberColumn()
            },
            {
                // 公务员医疗 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptPublicDelayAmt',
                ...numberColumn()
            },
            {
                // 公务员医疗 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptPublicInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 职业年金
        title: formatMessage({ id: 'salaryPayrollSocial.table.occupationalAnnuity' }),
        children: [
            {
                // 职业年金 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptAnnuityBaseAmt',
                ...numberColumn()
            },
            {
                // 职业年金 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptAnnuityCompanyAmt',
                ...numberColumn()
            },
            {
                // 职业年金 - 个人应缴
                // 个人应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.personAmt' }),
                dataIndex: 'encryptAnnuityPersonAmt',
                ...numberColumn()
            },
            {
                // 职业年金 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptAnnuityTotalAmt',
                ...numberColumn()
            },
            {
                // 职业年金 - 滞纳金
                // 滞纳金
                title: formatMessage({ id: 'salaryPayrollSocial.table.delayAmt' }),
                dataIndex: 'encryptAnnuityDelayAmt',
                ...numberColumn()
            },
            {
                // 职业年金 - 利息
                // 利息
                title: formatMessage({ id: 'salaryPayrollSocial.table.interestAmt' }),
                dataIndex: 'encryptAnnuityInterestAmt',
                ...numberColumn()
            }
        ]
    },

    {
        // 住房公积金
        title: formatMessage({ id: 'salaryPayrollSocial.table.housingFund' }),
        children: [
            {
                // 住房公积金 - 缴费基数
                // 缴费基数
                title: formatMessage({ id: 'salaryPayrollSocial.table.baseAmt' }),
                dataIndex: 'encryptFundBaseAmt',
                ...numberColumn()
            },
            {
                // 住房公积金 - 单位应缴
                // 单位应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.companyAmt' }),
                dataIndex: 'encryptFundCompanyAmt',
                ...numberColumn()
            },
            {
                // 住房公积金 - 个人应缴
                // 个人应缴
                title: formatMessage({ id: 'salaryPayrollSocial.table.personAmt' }),
                dataIndex: 'encryptFundPersonAmt',
                ...numberColumn()
            },
            {
                // 住房公积金 - 本金合计
                // 本金合计
                title: formatMessage({ id: 'salaryPayrollSocial.table.totalAmt' }),
                dataIndex: 'encryptFundTotalAmt',
                ...numberColumn()
            }
        ]
    }
]

export default salaryPayrollSocialModel
